
clear

cd "D:\data_replication"

import delimited data\firm_size_distribution\zeta_i_k.csv
rename v1 i_k 
rename v2 zeta_i_k
save data\firm_size_distribution\zeta_i_k.dta, replace


import delimited data\firm_size_distribution\eos_summary.csv, clear
gen i_k = _n
rename v1 eos_i_k

merge 1:1 i_k using data\firm_size_distribution\zeta_i_k.dta
gen gamma_i_k = zeta_i_k * (eos_i_k - 1)
egen gamma_median = median(gamma_i_k)
replace gamma_i_k = gamma_median if gamma_i_k == .
replace gamma_i_k = gamma_median if gamma_i_k < 0


keep i_k gamma_i_k
export delimited using data\firm_size_distribution\gamma_i_k.csv, replace
